package com.example.wo.jsbapplication;

import android.content.Context;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.widget.Toast;

public class NoteData extends SQLiteOpenHelper {
    final private String CREATE_NOTE =
            "create table tb_note("+"id INTEGER PRIMARY KEY AUTOINCREMENT,"
                                    +"title VARCHAR(20),"
                                    +"content VARCHAR(20))";

    private Context mContext;
    public NoteData(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
        super(context, "note.db", null, 2);
        mContext = context;
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        System.out.println("OnCreate");
        try {
            db.execSQL( CREATE_NOTE);
        }catch (SQLException e) {
            Toast.makeText(mContext, "数据表创建失败",
                    Toast.LENGTH_LONG).show();
        }

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        System.out.println("OnUpgrade");
    }
}
